const fs = require('fs')


//实现的功能,传入html模板后，可以像ejs，art-temple引擎一样，解析整个html模板文件，把name变量替换为数据

fs.readFile('html模板.html', { encoding: "utf-8", flag: "r" }, (err, data) => {
	if(err) {
		console.log(err)
	} else {
		let name = "111111231242354356"
		//匹配普通的变量
		let reg = /\{\{(.*?)\}\}/igs
		let result;
		while(result = reg.exec(data)) {
			//去除2边的空白
			let strKey = result[1].trim()
			data = data.replace(result[0], name)
		}

		console.log(data)

	}

})